import Types from '../OperationType';
import LoginTypes from '../../assets/js/LoginStateTypes';
import empty from '../../assets/js/util';
const state = {
  // loginState: localStorage.getItem('NewLoginState') ? JSON.parse(localStorage.getItem('NewLoginState')) : LoginTypes.NEED_REGISTER,
  loginState: empty.getStorage('NewLoginState', LoginTypes.NEED_REGISTER),
  /** 不要用这个读取用户数据 自己一条条拿 */
  userUid: empty.getStorage('userUid', '0'),
  userName: empty.getStorage('userName', ''),
  userPic: empty.getStorage('userPic', ''),
  userArea: empty.getStorage('userArea', ''),
  userCity: empty.getStorage('userCity', ''),
  userProvince: empty.getStorage('userProvince', ''),
  userOid: empty.getStorage('userOid', ''),
  userRec: empty.getStorage('userRec', '')
  // 强制绑定收集好的标志
};
const mutations = {
  [Types.SET_LOGIN_STATE](state, val) {
    empty.setStorage('NewLoginState', val, LoginTypes.NEED_REGISTER);
    state.loginState = JSON.parse(localStorage.getItem('NewLoginState'));
  },
  [Types.SET_USER_DATA](state, val) {
  },
  [Types.SET_USER_UID](state, val) {
    empty.setStorage('userUid', val, '0');
    state.userUid = JSON.parse(localStorage.getItem('userUid'));
  },
  [Types.SET_USER_NAME](state, val) {
    empty.setStorage('userName', val, '');
    state.userName = JSON.parse(localStorage.getItem('userName'));
  },
  [Types.SET_USER_PIC](state, val) {
    empty.setStorage('userPic', val, '');
    state.userPic = JSON.parse(localStorage.getItem('userPic'));
  },
  [Types.SET_USER_LEVEL](state, val) {
    empty.setStorage('userLevel', val, '');
    state.userLevel = JSON.parse(localStorage.getItem('userLevel'));
  },
  // [Types.SET_USER_SKELETON](state, val) {
  //   empty.setStorage('userSkeleton', val, '');
  //   state.userSkeleton = JSON.parse(localStorage.getItem('userSkeleton'));
  // },
  [Types.SET_USER_PROVINCE](state, val) {
    empty.setStorage('userProvince', val, '');
    state.userProvince = JSON.parse(localStorage.getItem('userProvince'));
  },
  [Types.SET_USER_CITY](state, val) {
    empty.setStorage('userCity', val, '');
    state.userCity = JSON.parse(localStorage.getItem('userCity'));
  },
  [Types.SET_USER_AREA](state, val) {
    empty.setStorage('userArea', val, '');
    state.userArea = JSON.parse(localStorage.getItem('userArea'));
  },
  [Types.SET_USER_OID](state, val) {
    empty.setStorage('userOid', val, '');
    state.userOid = JSON.parse(localStorage.getItem('userOid'));
  },
  [Types.SET_USER_REC](state, val) {
    empty.setStorage('userRec', val, '');
    state.userRec = JSON.parse(localStorage.getItem('userRec'));
  }
};
export default {
  state,
  // actions,
  mutations
};
